import os
import pathlib
# from test.File_List_Test import File_List_Test

import sys

class Run_Test(object):
    def __init__(self, _tests=None):
        self.tests = _tests

    def test_pool(self):
        test_pool = []
        test_case_fold = os.sep.join([os.path.dirname(__file__), 'test'])
        print("Find Test in {}".format(test_case_fold))
        for _root, _dir, _files in os.walk(test_case_fold):
            sys.path.insert(0, _root)
            for _file in _files:
                if _file.endswith('.py'):
                    case_name = os.path.splitext(_file)[0]
                    test_pool.append(case_name)
        print(sys.path)
        return test_pool

    def run(self):
        if self.tests is None:
            self.tests = self.test_pool()
        for test_name in self.tests:
            print("RUN Test Case: {}".format(test_name))
            test_case = __import__('File_List_Test.File_List_Test', fromlist=["File_List_Test"])()
            print(test_case.run())

if __name__ == "__main__":
    rt = Run_Test()
    rt.run()

    